<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: stats_stock_warning.php 120 2013-09-21 12:09:44Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 120 $
* 	zuletzt geaendert von:	$Author: peter $
* 	Datum:					$Date: 2013-09-21 12:09:44 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');
require(DIR_WS_INCLUDES . 'metatag.php');
?>
</head>
<body>
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellspacing="0" cellpadding="0">
  <tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
		<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
			<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
		</table>
	</td>
	<td class="boxCenter" valign="top">
		<table border="0" width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="2">
						<tr>
							<td width="100%">
								<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
						   			<tr>
						     			<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
									</tr>
								</table>
							</td>
      					</tr>
      					
      					<tr>
      						<td align="right">
      							<button class="button" type="button" onclick="window.open('stats_stock_warning_print.php?lng=<?php echo $_SESSION['languages_id'];?>', 'popup', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=500')" href="javascript:void();">&Uuml;bersicht drucken</button>
      						</td>
      					</tr>
      					<tr>
        					<td>
								<table border="0" width="100%" cellspacing="0" cellpadding="0">
									<table width="100%" cellspacing="0" cellpadding="0" class="dataTable">
									<thead>
										<tr class="dataTableHeadingRow">
											<td class="dataTableHeadingContent" align="left">
												Produkt Name
											</td>
											<td class="dataTableHeadingContent" align="center">
												Lagerbestand
											</td>
											<td class="dataTableHeadingContent" align="left">
												Artikel Nr
											</td>
									</thead>
											<?php
											  $products = $db->db_query("SELECT p.products_id, 
											  									p.products_quantity,
											  									p.products_model,
											  									pd.products_name 
											  								FROM 
											  									" . TABLE_PRODUCTS . " p, 
											  									" . TABLE_PRODUCTS_DESCRIPTION . " pd 
											  								WHERE 
											  									pd.language_id = '" . $_SESSION['languages_id'] . "' 
											  								AND 
											  									pd.products_id = p.products_id 
											  								ORDER BY 
											  									products_name");
											  									
											  while (!$products->EOF) {
											    echo '<tr>
											    		<td class="dataTableContent">
											    			<a href="' . href_link(FILENAME_CATEGORIES, 'pID=' . $products->fields['products_id'] . '&action=new_product') . '">
											    				<b>' . $products->fields['products_name'] . '</b>
											    			</a>
											    		</td>
											    		<td class="dataTableContent" align="center">'. $products->fields['products_quantity'] .'</td>
											    		<td class="dataTableContent">'.$products->fields['products_model'].'</td>
											    	</tr>';

												$products_attributes = $db->db_query("	SELECT
																							pov.products_options_values_name,
																							pa.attributes_stock
																						FROM
																							" . TABLE_PRODUCTS_ATTRIBUTES . " pa, 
																							" . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
																						WHERE
																							pa.products_id = '".$products_values['products_id'] . "' 
																						AND 
																							pov.products_options_values_id = pa.options_values_id 
																						AND 
																							pov.language_id = '" . $_SESSION['languages_id'] . "' 
																						ORDER BY 
																							pa.attributes_stock");
								
											    while (!$products_attributes->EOF) {
											      echo '<tr><td class="dataTableContent">&nbsp;&nbsp;&nbsp;&nbsp;-' . $products_attributes->fields['products_options_values_name'] . '</td><td width="50%" class="dataTableContent">';
											      if ($products_attributes->fields['attributes_stock'] <= '0') {
											        echo '<font color="ff0000"><b>' . $products_attributes->fields['attributes_stock'] . '</b></font>';
											      } else {
											        echo $products_attributes->fields['attributes_stock'];
											      }
											      echo '</td><td></td></tr>';
												  $products_attributes->MoveNext();
											    }
												$products->MoveNext();
											  }
											?>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</td>
</tr>
</table>
</div>

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>